/**
 * 
 */
package com.lanswon.service;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lanswon.common.enums.ArticleStatus;
import com.lanswon.dao.AboutUsMapper;
import com.lanswon.dao.ActivityMapper;
import com.lanswon.entity.AboutUs;
import com.lanswon.entity.Activity;
import com.lanswon.entity.ArticleVO;

/**
 * 
 * @ClassName: AboutService.java
 * @Description: 该类的功能描述
 *
 * @version: v1.0.0
 * @author: zm
 * @date: 2018年6月20日 上午10:17:47
 *
 */
@Service
public class AboutService {
	@Autowired
	private AboutUsMapper aboutUsMapper;

	/**
	 * @return
	 */
	public Map<String, Object> showDetail() {
		Map<String, Object> viewMap = new HashMap<>();
		try {
			viewMap.put("code", 0);
			viewMap.put("data", load());
		} catch (Exception e) {
			e.printStackTrace();
			viewMap.put("code", 1);
			viewMap.put("message", "查询失败");
		}
		return viewMap;
	}

	/**
	 * @return
	 */
	public Map<String, Object> load() {
		Map<String, Object> viewMap = new HashMap<>();
		AboutUs aboutUs = aboutUsMapper.selectByPrimaryKey(54L);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		viewMap.put("aboutUsId", aboutUs.getAboutUsId());
		viewMap.put("aboutUsName", aboutUs.getAboutUsName());
		viewMap.put("releaseTime", aboutUs.getReleaseTime() == null ? "" : sdf.format(aboutUs.getReleaseTime()));
		viewMap.put("content", aboutUs.getContent());
		viewMap.put("readNum", aboutUs.getReadNum());
		return viewMap;
	}

	/**
	 * @param aboutUs
	 * @return
	 */
	public Map<String, Object> update(AboutUs aboutUs) {
		Map<String, Object> viewMap = new HashMap<>();
		try {
			aboutUsMapper.updateByPrimaryKeySelective(aboutUs);
			viewMap.put("code", 0);
		} catch (Exception e) {
			e.printStackTrace();
			viewMap.put("code", 1);
			viewMap.put("message", "查询失败");
		}
		return viewMap;
	}
}
